<php>
	$this->display(tpl('head'));
	$gd_water[$setting['gd_water']]='checked';
	$gd[$setting['gd']]='checked';
	$gd_time[$setting['gd_time']]='checked';
	$gd_water_position[$setting['gd_water_position']]='checked';
	if($setting['gd_water']==2) {$words ='';$state='words';} else{$words ='style="display: none;"';}  
	if($setting['gd_water']==1) {$img ='';$state='img';} else{$img ='style="display: none;"';}
	$gd_thumb[$setting['gd_thumb']]='checked';
	$gd_copy[$setting['gd_copy']]='checked';
</php>
<fieldset class="layui-elem-field layui-field-title">
  <legend>水印及缩略图设置</legend>
</fieldset>
<script src="/public/global/js/colpick.js" type="text/javascript" charset="utf-8"></script>
<form id="SETForm" class="layui-form" method="post">
	<table class="layui-table my-tabel">
		<tbody>
			<tr>
				<td>是否启用GD库</td>
				<td>
					<input type="radio" lay-filter='gd' name="web[gd]" title="关闭" value="0" {{$gd[0]}}/>
					<input type="radio" lay-filter='gd' name="web[gd]" title="开启" value="1" {{$gd[1]}}/>
					如果不支持请选择否，否则无法发布/修改内容
				</td>
			</tr>
			<tr>
				<td>如果开启以下操作在</td>
				<td>
					<input type="radio" lay-filter='gd' name="web[gd_time]" title="上传图片时" value="0" {{$gd_time[0]}}/>
					<input type="radio" lay-filter='gd' name="web[gd_time]" title="内容发布时" value="1" {{$gd_time[1]}}/>
				</td>
			</tr>
			<tr>
				<td>操作前是否备份原图</td>
				<td>
					<input type="radio" name="web[gd_copy]" title="直接替换" value="0" {{$gd_copy[0]}}/>
					<input type="radio" name="web[gd_copy]" title="备份原图" value="1" {{$gd_copy[1]}}/>
				</td>
			</tr>
		</tbody>
	</table>
	<table class="layui-table my-tabel">
		<tbody>
			<tr>
				<td>缩略图裁剪方式</td>
				<td>
					<input type="radio" name="web[gd_thumb]" title="自动适应宽高" value="1" {{$gd_thumb[1]}}/>
					<input type="radio" name="web[gd_thumb]" title="按比例缩小后用白色填充" value="2" {{$gd_thumb[2]}}/>
					<input type="radio" name="web[gd_thumb]" title="直接按照下面的比例压缩" value="3" {{$gd_thumb[3]}}/>
					<p>如果选择"自动适应宽高"裁剪的图片有可能比预设置的要小</p>
				</td>
			</tr>
			<tr>
				<td>缩略图大小设置</td>
				<td>
					宽: <input type="number" class="layui-input my-input" style="width: 100px;" name="web[gd_thumb_width]"  value="{{$setting['gd_thumb_width']}}" />
					高: <input type="number" class="layui-input my-input" style="width: 100px;" name="web[gd_thumb_height]"  value="{{$setting['gd_thumb_height']}}" />
				</td>
			</tr>
		</tbody>
	</table>
	<table class="layui-table my-tabel">
		<tbody>
			<tr>
				<td>是否启用水印功能</td>
				<td>
					<input type="radio" lay-filter='gd_water' name="web[gd_water]" title="不启用" value="0" {{$gd_water[0]}}/>
					<input type="radio" lay-filter='gd_water' name="web[gd_water]" title="图片水印" value="1" {{$gd_water[1]}}/>
					<input type="radio" lay-filter='gd_water' name="web[gd_water]" title="文字水印" value="2" {{$gd_water[2]}}/>
					<p class="red">不管是否启用文字水印都需要上传一个字体文件.然后[字体文件]进行设置一下.因为验证码要用到</p>
				</td>
			</tr>
			<tr id="words" {{$words }}>
				<td>文字水印设置</td>
				<td>
					文字内容：<input type="text" class="layui-input my-input" name="web[gd_water_text]"  value="{{$setting['gd_water_text']}}" />
					字体大小：<input type="number" class="layui-input my-input" style="width: 100px;" name="web[gd_water_text_size]"  value="{{$setting['gd_water_text_size']}}" />
					字体颜色：<input type="text" id="color" class="layui-input my-input" style="width: 100px;" name="web[gd_water_text_color]"  value="{{$setting['gd_water_text_color']}}" />
					<div id="picker"></div>
				   	<div style="margin-top: 10px;">
				   		字体文件：<input type="text" class="layui-input my-input" name="web[gd_water_text_font]" value="{{$setting['gd_water_text_font']}}" />
				   		必须把字体文件保存在public/global/font/文件夹下。然后填写该文件名称加后戳就可以了，比如:font.ttf
				   	</div>
				</td>
			</tr>
			<tr id="img" {{$img}}>
				<td>图片水印地址</td>
				<td>
					<input type="text" class="layui-input my-input" name="web[gd_water_img]"  value="{{$setting['gd_water_img']}}" />
					必须把文件保存在public/global/images/文件夹下
				</td>
			</tr>
			<tr>
				<td>水印透明度</td>
				<td>
					<input type="number" class="layui-input my-input" style="width: 100px;" name="web[gd_water_alpha]"  value="{{$setting['gd_water_alpha']}}" />
					<p id="words_alpha" {{$words }}>值0-127,数值越低，清晰度越高，反之则模糊。默认为0</p>
					<p id="img_alpha" {{$img}}>值0-100,数值越高，清晰度越高，反之则模糊。默认为100</p>
				</td>
			</tr>
			<tr>
				<td>图片小于该值不起用水印</td>
				<td>
					宽: <input type="number" class="layui-input my-input" style="width: 100px;" name="web[gd_water_min_width]"  value="{{$setting['gd_water_min_width']}}" />
					高: <input type="number" class="layui-input my-input" style="width: 100px;" name="web[gd_water_min_height]"  value="{{$setting['gd_water_min_height']}}" />
					全为0时都水印,如果只设置一个值，则只以该值做参考
				</td>
			</tr>
			<tr>
				<td>水印位置</td>
				<td>
					<div>
						<input type="radio" name="web[gd_water_position]" title="上左" value="1" {{$gd_water_position[1]}}/>
						<input type="radio" name="web[gd_water_position]" title="上中" value="2" {{$gd_water_position[2]}}/>
						<input type="radio" name="web[gd_water_position]" title="上右" value="3" {{$gd_water_position[3]}}/>
					</div>
					<div>
						<input type="radio" name="web[gd_water_position]" title="中左" value="4" {{$gd_water_position[4]}}/>
						<input type="radio" name="web[gd_water_position]" title="中心" value="5" {{$gd_water_position[5]}}/>
						<input type="radio" name="web[gd_water_position]" title="中右" value="6" {{$gd_water_position[6]}}/>
					</div>
					<div>
						<input type="radio" name="web[gd_water_position]" title="下左" value="7" {{$gd_water_position[7]}}/>
						<input type="radio" name="web[gd_water_position]" title="下中" value="8" {{$gd_water_position[8]}}/>
						<input type="radio" name="web[gd_water_position]" title="下右" value="9" {{$gd_water_position[9]}}/>
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="2" class="my_button center" align="center">
					<input type="hidden" name="step" id="step" value="post" />
					<button class="layui-btn">立即提交</button>
				</td>
			</tr>
		</tbody>
	</table>
</form>
<script type="text/javascript">
	$("#color").css('background-color', '#{{$setting['gd_water_text_color'] }}');
	$("#color").css('color', '#fff');
	$('#color').colpick({
		layout: 'hex',
		submit: 0,
		colorScheme: 'dark',
		onChange: function(hsb, hex, rgb, el, bySetColor) {
			$(el).css('border-color', '#' + hex);
			$(el).css('color', '#FFF');
			$(el).css('background-color', '#' + hex);
			if(!bySetColor) $(el).val(hex);
		}
	}).keyup(function() {
		$(this).colpickSetColor(this.value);
	});
</script>
<script>
	var state='{{$state }}';
	layui.use(['form'], function() {
		var form = layui.form;
		form.on('radio(gd_water)', function(data){
			if(data.value==0){
				return false;
			}
			layer.msg('更改了水印方式，必须水印透明度的值也一并修改，因为他们是相反的', {icon: 1});
			if(state){
				$('#'+state+'_alpha').hide();
				$('#'+state).hide();
			}
		 	if(data.value==2){
		  		state='words';
		  		$('#'+state+"_alpha").show();
				$('#'+state).show();
		 	}else if(data.value==1){
		  		state='img';
		  		$('#'+state+"_alpha").show();
				$('#'+state).show();
		 	}
		});  
	});
</script>
<php> $this->display(tpl('foot')); </php>
